package com.zycfc.zsf.boot.office.excel.util;

import com.zycfc.zsf.boot.office.excel.constant.*;
import com.zycfc.zsf.boot.exception.*;
import java.util.*;

public class AssertUtils
{
    public static void isNull(final Object val, final String errCode, final String errMsg) throws ServiceException {
        if (checkNull(val)) {
            throw new ServiceException((IExceptionCode)OfficeExceptionCode.DATA_VALID_ERROR);
        }
    }
    
    public static void isEmpty(final String val, final String errCode, final String errMsg) throws ServiceException {
        if (isBlank(val)) {
            throw new ServiceException((IExceptionCode)OfficeExceptionCode.DATA_VALID_ERROR);
        }
    }
    
    public static <T> void isEmpty(final List<T> val, final String errCode, final String errMsg) throws ServiceException {
        if (val == null || val.isEmpty()) {
            throw new ServiceException((IExceptionCode)OfficeExceptionCode.DATA_VALID_ERROR);
        }
    }
    
    public static void isTrue(final boolean val, final String errCode, final String errMsg) throws ServiceException {
        if (val) {
            throw new ServiceException((IExceptionCode)OfficeExceptionCode.DATA_VALID_ERROR);
        }
    }
    
    private static boolean checkNull(final Object val) {
        return val == null;
    }
    
    private static boolean isBlank(final String str) {
        final int strLen;
        if (str == null || (strLen = str.length()) == 0) {
            return true;
        }
        for (int i = 0; i < strLen; ++i) {
            if (!Character.isWhitespace(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }
}
